package com.zhentao.controller;

import com.zhentao.file.service.impl.FileStorageServiceImpl;
import com.zhentao.model.common.dtos.ResponseResult;
import io.minio.errors.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * @Date 2024/5/9 10:51
 * @Author xdm
 **/
@RestController
@RequestMapping("/minio")
public class MinioTestController {
    @Autowired
    private FileStorageServiceImpl fileStorageService;

    @RequestMapping("/uploadHtml")
    public ResponseResult uplaodHtml() throws FileNotFoundException {

        FileInputStream inputStream=new FileInputStream("D://03.html");

        try {
           String url =fileStorageService.uploadHtmlFile("03.html",inputStream);
           return ResponseResult.okResult(url);
        } catch (Exception e){
            return ResponseResult.errorResult(303,"minio异常");
        }

    }
}